/**
 * Created by IAN on 2016/10/14.
 */
$(function () {
    //日期控件
    var close = {
        dateCell:"#closeTime",
        format: 'YYYY-MM-DD hh:mm:ss',
        isinitVal:false,
        festival:false,
        ishmsVal:false,
        isTime:true,
        maxDate: '2099-06-16 23:59:59'
    };
    jeDate(close);

    //根据id,读取数据到页面
    var uid = getQueryString("uid");
    var sel = $.Params.create();
    sel.addParams("id",uid);
    sel.ajax(getIP()+"metLive/getMETlist",function(data){
        if(data.success){
            var liveTitle =data.result[0].liveTitle;
			var startTime = data.result[0].startTime;
			var endTime = data.result[0].endTime;
            var joinId = data.result[0].joinId;
			var tokenId = data.result[0].tokenId;
            var URL = data.result[0].URL;
            var selClassify = data.result[0].ccdtProject;
            var is_ccdt = data.result[0].is_ccdt;
            var remark = data.result[0].remark;
            var closeTime = data.result[0].closeTime;
            

            $("#liveTitle").val(liveTitle);
            $("#startTime").val(startTime);
            $("#endTime").val(endTime);
            $("#joinId").val(joinId);
            $("#tokenId").val(tokenId);
            $("#URL").val(URL);
            $("#selClassify").find("option[value="+selClassify+"]").attr("selected","selected");
            $("#remark").val(remark);
            $("#closeTime").val(closeTime);
        }
    })

    //实时预览图片
    $("#loadImg").on("change", function(e){
        var src, url = window.URL || window.webkitURL || window.mozURL, files = e.target.files;
        for (var i = 0, len = files.length; i < len; ++i) {
            var file = files[i];

            if (url) {
                src = url.createObjectURL(file);
            } else {
                src = e.target.result;
            }

            $("#pUrl").attr('src', src);
        }
    });

    //修改信息
    $("#eid").val(uid);
    $("#updateData").on("click",function(){
        $("#updateForm").attr("action",getIP()+"metLive/updateMetLive");
        $("#updateForm").submit();
    })

    //取消修改信息
    $("#cancelUpdate").on("click",function() {
        history.back(-1);
    })
});
